/* GUI CONVERTED from rccadj.p (converter v1.75) Tue Apr 10 12:03:22 2001 */
/* rccadj.p - Release Management Customer Schedules                           */
/* Copyright 1986-2002 QAD Inc., Carpinteria, CA, USA.                        */
/* All rights reserved worldwide.  This is an unpublished work.               */
/* $Revision: 1.12.1.5 $                                                         */
/*V8:ConvertMode=Maintenance                                                  */
/* REVISION: 7.3    LAST MODIFIED: 10/09/92           BY: WUG *G462*          */
/* REVISION: 7.3    LAST MODIFIED: 10/18/93           BY: WUG *GG36*          */
/* REVISION: 7.3    LAST MODIFIED: 11/01/94           BY: ame *GN84*          */
/* REVISION: 7.5    LAST MODIFIED: 12/13/94           BY: mwd *J034*          */
/* REVISION: 7.3    LAST MODIFIED: 01/18/95           BY: bcm *G0CP*          */
/* REVISION: 7.3    LAST MODIFIED: 03/23/95           BY: aed *G0J0*          */
/* REVISION: 7.5    LAST MODIFIED: 10/25/95           BY: dpm *J044*          */
/* REVISION: 7.4    LAST MODIFIED: 08/25/95           BY: bcm *G0TB*          */
/* REVISION: 8.5    LAST MODIFIED: 12/01/97     BY: *J275* Suresh Nayak       */
/* REVISION: 8.6E     LAST MODIFIED: 02/23/98   BY: *L007* A. Rahane          */
/* REVISION: 8.6E     LAST MODIFIED: 05/20/98   BY: *K1Q4* Alfred Tan         */
/* REVISION: 8.6E     LAST MODIFIED: 10/04/98   BY: *J314* Alfred Tan         */
/* REVISION: 9.1      LAST MODIFIED: 07/07/99   BY: *J3HR* Sachin Shinde      */
/* REVISION: 9.1      LAST MODIFIED: 03/24/00   BY: *N08T* Annasaheb Rahane   */
/* REVISION: 9.1      LAST MODIFIED: 08/12/00   BY: *N0KP* Mark Brown         */
/* REVISION: 9.1      LAST MODIFIED: 01/25/01   BY: *M10W* Sandeep p.         */
/* Old ECO marker removed, but no ECO header exists *F0PN*                    */
/* $Revision: 1.12.1.5 $    BY: Jean Miller    DATE: 03/22/01 ECO: *P008*          */
/******************************************************************************/
/* All patch markers and commented out code have been removed from the source */
/* code below. For all future modifications to this file, any code which is   */
/* no longer required should be deleted and no in-line patch markers should   */
/* be added.  The ECO marker should only be included in the Revision History. */
/******************************************************************************/
/* CUM SHIP ADJUST */

{mfdtitle.i "b+ "}

/* ********** Begin Translatable Strings Definitions ********* */

&SCOPED-DEFINE rccadj_p_1 "Prior Day Cum Shipped"
/* MaxLen: Comment: */

&SCOPED-DEFINE rccadj_p_2 "A/R"
/* MaxLen: Comment: */

&SCOPED-DEFINE rccadj_p_3 "Prior Day Cum Shipped Date"
/* MaxLen: Comment: */

&SCOPED-DEFINE rccadj_p_4 "Adjust or Reset (A/R)"
/* MaxLen: Comment: */

&SCOPED-DEFINE rccadj_p_5 "Cum Shipped"
/* MaxLen: Comment: */

&SCOPED-DEFINE rccadj_p_6 "Cum Shipped Start Date"
/* MaxLen: Comment: */

&SCOPED-DEFINE rccadj_p_7 "Remarks"
/* MaxLen: Comment: */

/* ********** End Translatable Strings Definitions ********* */

define variable adj_type like mfc_logical format {&rccadj_p_2}
                                          label {&rccadj_p_4} initial yes.
define variable remarks   as character format "x(24)" label {&rccadj_p_7}.
define variable adjust    as logical initial yes.
define variable reset     as logical initial no.
define variable scx_recid as recid.
define variable sod_recid as recid.
define variable tr_recid  as recid.
define variable last_cum_qty     as decimal.
define variable last_pri_cum_qty as decimal.
define  variable impexp   like mfc_logical no-undo.
define variable impexp_label as character format "x(8)" no-undo.
define variable undo_adju1 as logical.

{rcordfrm.i}


/*GUI preprocessor Frame A define */
&SCOPED-DEFINE PP_FRAME_NAME A

FORM /*GUI*/ 
   
 RECT-FRAME       AT ROW 1 COLUMN 1.25
 RECT-FRAME-LABEL AT ROW 1 COLUMN 3 NO-LABEL VIEW-AS TEXT SIZE-PIXELS 1 BY 1
 SKIP(.1)  /*GUI*/
{rcordfma.i}
 SKIP(.4)  /*GUI*/
with frame a side-labels width 80 attr-space NO-BOX THREE-D /*GUI*/.

 DEFINE VARIABLE F-a-title AS CHARACTER INITIAL "".
 RECT-FRAME-LABEL:SCREEN-VALUE in frame a = F-a-title.
 RECT-FRAME-LABEL:HIDDEN in frame a = yes.
 RECT-FRAME:HEIGHT-PIXELS in frame a =
  FRAME a:HEIGHT-PIXELS - RECT-FRAME:Y in frame a - 2.
 RECT-FRAME:WIDTH-CHARS IN FRAME a = FRAME a:WIDTH-CHARS - .5.  /*GUI*/

/*GUI preprocessor Frame A undefine */
&UNDEFINE PP_FRAME_NAME



/* SET EXTERNAL LABELS */
setFrameLabels(frame a:handle).

FORM /*GUI*/ 
   
 RECT-FRAME       AT ROW 1 COLUMN 1.25
 RECT-FRAME-LABEL AT ROW 1 COLUMN 3 NO-LABEL VIEW-AS TEXT SIZE-PIXELS 1 BY 1
 SKIP(.1)  /*GUI*/
adj_type             colon 30
   Remarks              colon 30
   skip(1)
   sod_cum_qty[1]       label {&rccadj_p_5} colon 30
   sod_cum_qty[2]       label {&rccadj_p_1} colon 30
   skip(1)
   sod_cum_date[1]       colon 30 label {&rccadj_p_6}
   sod_cum_date[2]       colon 30 label {&rccadj_p_3}
 SKIP(.4)  /*GUI*/
with frame b width 80 attr-space side-labels NO-BOX THREE-D /*GUI*/.

 DEFINE VARIABLE F-b-title AS CHARACTER INITIAL "".
 RECT-FRAME-LABEL:SCREEN-VALUE in frame b = F-b-title.
 RECT-FRAME-LABEL:HIDDEN in frame b = yes.
 RECT-FRAME:HEIGHT-PIXELS in frame b =
  FRAME b:HEIGHT-PIXELS - RECT-FRAME:Y in frame b - 2.
 RECT-FRAME:WIDTH-CHARS IN FRAME b = FRAME b:WIDTH-CHARS - .5.  /*GUI*/


/* SET EXTERNAL LABELS */
setFrameLabels(frame b:handle).

mainloop:
repeat:
/*GUI*/ if global-beam-me-up then undo, leave.


   /* GET SCHEDULED ORDER */
   /* 3rd VALUE ENABLES SITE SECURITY CHECK                */
   {rcgetord.i "old" " " "validate"}

   sod_recid = recid(sod_det).
   find sod_det where recid(sod_det) = sod_recid exclusive-lock.
   find so_mstr where so_nbr = sod_nbr no-lock.

   do with frame b:
      display
         sod_cum_qty[1]
         sod_cum_qty[2]
         sod_cum_date[1]
         sod_cum_date[2].

      assign
         last_cum_qty = sod_cum_qty[1]
         last_pri_cum_qty = sod_cum_qty[2].

      update
         adj_type
         remarks.

      if adj_type = adjust then do:

         update
            sod_cum_qty[1]
            sod_cum_qty[2].

         if sod_cum_qty[1] = last_cum_qty and
            sod_cum_qty[2] <> last_pri_cum_qty
         then do:
            sod_cum_qty[1] = sod_cum_qty[1] + sod_cum_qty[2] -
            last_pri_cum_qty.
            display
               sod_cum_qty[1].
         end.

      end.

      else do:

         assign
            sod_cum_qty[1] = 0
            sod_cum_qty[2] = 0.

         display
            sod_cum_qty[1]
            sod_cum_qty[2].

      end.

      update
         sod_cum_date[1]
         sod_cum_date[2].

      undo_adju1 = true.

      /* PASSING last_cum_qty INSTEAD OF last_pri_cum_qty. */
      {gprun.i ""rccadju1.p""
         "(input sod_recid,
           input global_db,
           input adj_type,
           input remarks,
           input adjust,
           input so_cust,
           input last_cum_qty,
           input-output undo_adju1)"}
/*GUI*/ if global-beam-me-up then undo, leave.


      if undo_adju1 then
         undo mainloop, retry.

      {gprun.i ""rcmrw.p""
         "(input sod_nbr, input sod_line, input no)"}
/*GUI*/ if global-beam-me-up then undo, leave.


      display
         sod_cum_qty[1]
         sod_cum_qty[2]
         sod_cum_date[1]
         sod_cum_date[2].

   end. /* DO WITH FRAME B */

   release sod_det.

end.
/*GUI*/ if global-beam-me-up then undo, leave.
 /* MAINLOOP */
